
/**
 * Copyright (c) subnew
 * Licensed under the GPL;
 * @email:joseanluo@gmail.com
 * @Title: OperatorBean.java
 * @Package com.subnew.mango.modules.sys.service.operator
 */
package com.subnew.mango.modules.sys.service.operator;

import java.util.List;

import org.springframework.stereotype.Service;

import com.subnew.mango.frame.exception.ExceptionEnum;
import com.subnew.mango.frame.exception.ServiceException;
import com.subnew.mango.frame.service.BaseBean;
import com.subnew.mango.frame.utils.StringUtil;
import com.subnew.mango.modules.sys.entity.SysOperator;

/**
 * 系统操作员Service
 *@author JoseanLuo  
 * @date  2014年12月15日 上午9:41:15
 * @version V1.0 
 */
@Service("OperatorManager")
@SuppressWarnings("unchecked")
public class OperatorBean  extends BaseBean<SysOperator, Long> implements OperatorManager{

	/* (non-Javadoc)
	 * @see com.subnew.mango.modules.sys.service.operator.OperatorManager#findUnique(com.subnew.mango.modules.sys.entity.SysOperator)
	 */
	@Override
	public SysOperator findUnique(SysOperator operator) throws ServiceException {

		//密码用户名不能空
		if(StringUtil.isBlank(operator.getLoginname())||StringUtil.isBlank(operator.getPwd()))
		{
			logger.error("OperatorBean.findUnique:用户名/密码不能为空");
			throw new ServiceException(ExceptionEnum.DAO_20000);
		}
		List<SysOperator> list =(List<SysOperator>) this.createQuery("FROM SysOperator u WHERE u.loginname= ? and u.pwd = ?", new Object[]{operator.getLoginname(),operator.getPwd()}).list();
		
		return list.isEmpty()?null:list.get(0);
	}

}
